import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';
import 'package:signage/app/modules/cast/views/cast_view.dart';
import 'package:signage/app/modules/device/views/device_view.dart';
import 'package:signage/app/modules/profile/views/profile_view.dart';
import 'package:signage/app/modules/template/views/template_view.dart';
import 'package:signage/l10n/l10n.dart';

import '../controllers/home_controller.dart';

class HomeView extends GetView<HomeController> {
  const HomeView({super.key});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Obx(() => IndexedStack(
            index: controller.selectedIndex.value,
            children: const [
              CastView(),           // 投屏页面
              DeviceView(),   // 设备管理页面
              TemplateView(),       // 模板管理页面
              ProfileView(),
            ],
          )),
      bottomNavigationBar: Obx(
        () => BottomNavigationBar(
          backgroundColor: Colors.white,
          type: BottomNavigationBarType.fixed,
          currentIndex: controller.selectedIndex.value,
          onTap: controller.changeIndex,
          selectedFontSize: 12.sp,
          unselectedFontSize: 12.sp,
          items: [
            BottomNavigationBarItem(
              icon: Image.asset(
                'assets/images/Frame 15@2x.png',
                width: 27.w,
              ),
              activeIcon: Image.asset('assets/images/Frame 11@2x.png',
                width: 27.w,),
              label: AppLocalizations.of(Get.context!)!.translate('cast'),
            ),
            BottomNavigationBarItem(
             icon: Image.asset(
                'assets/images/Frame 16@2x.png',
                width: 27.w,
              ),
              activeIcon: Image.asset('assets/images/Frame 12@2x.png',
                width: 27.w,),
              label: AppLocalizations.of(Get.context!)!.translate('device'),
            ),
            BottomNavigationBarItem(
              icon: Image.asset(
                'assets/images/Frame 17@2x.png',
                width: 27.w,
              ),
              activeIcon: Image.asset('assets/images/Frame 13@2x.png',
                width: 27.w,),
              label: AppLocalizations.of(Get.context!)!.translate('template'),
            ),
            BottomNavigationBarItem(
              icon: Image.asset(
                'assets/images/Frame 18@2x.png',
                width: 27.w,
              ),
              activeIcon: Image.asset('assets/images/Frame 14@2x.png',
                width: 27.w,),
              label: AppLocalizations.of(Get.context!)!.translate('profile'),
            ),
          ],
        ),
      ),
    );
  }
}
